package com.leetcode.partition21;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/3/16 8:52
 */
public class LC2044统计按位或能得到最大值的子集数目_枚举 {

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        int[] a = new int[ss.length];
        for (int i = 0; i < ss.length; i++) a[i] = Integer.parseInt(ss[i]);
        writer.write(countMaxOrSubsets(a) + "\n");
        writer.flush();
    }

    public static int countMaxOrSubsets(int[] a) {
        int max = 0, cnt = 0, n = a.length;
        for (int i = 0; i < 1 << n; i++) {
            int u = 0;
            for (int j = 0; j < n; j++) {
                if ((i >> j & 1) == 1) u |= a[j];
            }
            if (u > max) {
                cnt = 1;
                max = u;
            } else if (u == max) {
                cnt++;
            }
        }
        return cnt;
    }
}
